package ynu.edu.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import org.apache.ibatis.annotations.Param;

import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import ynu.edu.user.domain.po.DailyUserStat;
import ynu.edu.user.domain.po.User;

import java.time.LocalDateTime;
import java.util.List;


public interface UserMapper extends BaseMapper<User> {
    @Update("update user set balance = balance - #{totalFee} where id = #{userId}")
    void updateMoney(@Param("userId") Long userId, @Param("totalFee") Integer totalFee);

//    @Select({
//            "SELECT",
//            "    DATE(create_time) AS date,",
//            "    COUNT(*) AS count",
//            "FROM user",
//            "WHERE create_time >= CURDATE() - INTERVAL 6 DAY",
//            "GROUP BY DATE(create_time)",
//            "ORDER BY DATE(create_time)"
//    })
    List<DailyUserStat> selectUserGrowthIn7Days();

    @Select("select count(id) from user")
    Long selectTotalUserCount();
}
